<style>
  table#table{
    border:1px solid #000;
    font-size:12px;
    width:100%;
    margin-bottom:25px;
  }

  table{
    border-collapse:collapse;
    width:100%;
   	margin:20px;
  }
  table#table tr td{
    border:1px solid #000;
    padding:2px 6px;
  }
  a{
    color:#000;
    text-decoration: none
  }
  	p,li{
		font-size: 12px;
	}
	table#block tr td{
		border:1px solid #000;
	}
</style>
<table>
  <tr>
    <td style="font-size:20; text-align:center;font-weight:bold;"><?=$school_name;?></td>
  </tr>

  <tr>
    <td style="font-size:12px; text-align:center;font-weight:bold;">School Year: <?=$school_year;?></td>
  </tr>
  <tr>
    <td style="font-size:12px; text-align:center;font-weight:bold;"><?=$print_title;?></td>
  </tr>
</table>


<?if($all_block_students):?>
	<?foreach($all_block_students as $k => $v):?>
		<?foreach(array_chunk($v,$chunk_size) as $nak => $newarray_v):?>
			<p style="font-size:12px;margin:0 2px 0 0;padding:0;font-weight:bold;border-bottom:1px dotted #000"><strong><?=strtoupper($k.' '.($nak+1));?></strong></p>
			<? usort($newarray_v, function($a,$b) {if($a->gender == 'male'){return -1;}else{return 1;}});?>
			<div style="margin-top:2px;">
				<!-- MALE-->
				<div style="display:inline;width:49%;float:left;padding:1px 3px;">
					<p style="margin:0;padding:0;">Male</p>
					<?foreach($newarray_v as  $num => $stud):?>
						<?if($stud->gender == 'male'):?>   
							<ul style="clear:both;list-style-type:none;margin:0;padding:0;">
								<li><?=($num+1).') '.ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob);?>) - <?=$stud->dob;?></li>
							</ul>
						<?endif;?>
					<?endforeach;?>
				</div>

				<!-- FEMALE-->
				<div style="display:inline;width:49%;float:right;padding:1px 3px;">
					<p style="margin:0;padding:0;">Female</p>
					<?foreach($newarray_v as  $num => $stud):?>
						<?if($stud->gender == 'female'):?>   
							<ul style="clear:both;list-style-type:none;margin:0;padding:0;">
								<li><?=($num+1).') '.ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob);?>) - <?=$stud->dob;?></li>
							</ul>
						<?endif;?>
					<?endforeach;?>
				</div>
			</div>
			<?endforeach;?> 
		<?endforeach;?> 
<?else:?>
	<?if($section):?>
	<? foreach($section as $k => $v): ?>
	<div style="margin-top:2px;">
	  <p style="font-size:12px;margin:0 2px 0 0;padding:0;font-weight:bold;border-bottom:1px dotted #000">Section : <?=$v['sname'];?>, Block: <?=$v['bname'] == NULL ? 'No Block' : $v['bname'];?> , Adviser: <?=$v['adviser'];?></p>
	  <div style="display:inline;width:49%;float:left;padding:1px 3px;">
	    <?if($v['male']):?>   
	      <p style="margin:0;padding:0;">Male - (<?=count($v['male'])?>)</p>
	      <ul style="clear:both;list-style-type:decimal;">

	          <?foreach($v['male'] as $stud):?>
	            <li> <?=ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob);?>) - <?=$stud->dob;?></li>
	          <?endforeach;?>

	      </ul>
	    <?else:?>
	      <p style="margin:0;padding:0;">Male - (0)</p>
	    <?endif;?>
	  </div>
	  <div style="display:inline;width:49%;float:right;padding:1px 3px;">
	    <?if($v['female']):?>   
	      <p style="margin:0;padding:0;">Female - (<?=count($v['female'])?>)</p>
	      <ul style="clear:both;list-style-type:decimal;">
	          <?foreach($v['female'] as $stud):?>
	            <li><?=ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob);?>) - <?=$stud->dob;?></li>
	          <?endforeach;?>
	      </ul>
	    <?else:?>
	      <p style="margin:0;padding:0;">Female - (0)</p>
	    <?endif;?>
	  </div>
	</div>
	<p style="text-align:center;margin:0;padding:0;">&#8226;&#8226;&#8226;</p>
	<?endforeach;?>
	<?endif;?>

	<?if($usection):?>
	<p style="font-size:12px;margin:0 2px 0 0;padding:0;font-weight:bold;border-bottom:1px dotted #000">Section Unassigned</p>
	<div style="margin-bottom:5px;">
	  <div style="display:inline;width:49%;float:left;padding:1px 3px;">
	    <?if($usection['male']):?>    
	      <p style="margin:0;padding:0;">Male - (<?=count($usection['male'])?>)</p>
	      <ul style="clear:both;list-style-type:decimal;">
	          <?foreach($usection['male'] as $stud):?>
	            <li> <?=ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob);?>) - <?=$stud->dob;?></li>
	          <?endforeach;?>
	      </ul>
	    <?else:?>
	      <p style="margin:0;padding:0;">Male - (0)</p>
	    <?endif;?>
	  </div>
	  <div style="display:inline;width:49%;float:right;padding:1px 3px;">
	    <?if($usection['female']):?>    
	      <p style="margin:0;padding:0;">Female - (<?=count($usection['female'])?>)</p>
	      <ul style="clear:both;list-style-type:decimal;">
	          <?foreach($usection['female'] as $stud):?>
	            <li> <?=ucwords(strtolower($stud->fullname)).' - ('.ageMonths($stud->dob)?>) - <?=$stud->dob;?></li>
	          <?endforeach;?>
	      </ul>
	    <?else:?>
	      <p style="margin:0;padding:0;">Male - (0)</p>
	    <?endif;?>
	  </div>
	</div>
	<?endif;?>
<?endif;?>